import * as service from "../../service";
import { ISearch } from "./interface";
const search: ISearch = {
  namespaced: true,
  state: {
    msg: [],
  },
  actions: {
    async getSearch({ commit }, { kw }) {
      const result = await service.fetchSearch(kw);
      const action = {
        type: "GET_search",
        payload: result,
      };
      commit(action);
    },
  },
  mutations: {
    GET_search(state, action) {
      if (action.payload?.status != 0) {
        state.msg = action.payload.data;
      } else {
        return;
      }
    },
  },
};
export default search;
